#ifndef __MOTOR_H
#define __MOTOR_H


#include "stm32f4xx.h"




#define PIN_CMD		GPIO_PIN_15
#define GPIO_CMD	GPIOE     
#define PIN_A		GPIO_PIN_8	
#define GPIO_A 		GPIOF    	
#define PIN_B		GPIO_PIN_0
#define GPIO_B 		GPIOA     
#define PIN_C		GPIO_PIN_9
#define GPIO_C 		GPIOD	  
#define PIN_D		GPIO_PIN_6
#define GPIO_D 		GPIOF  


#define RUN_MAX 0xFFFFFFFF

struct motor;

typedef void (*MOTORINIT)(void);
typedef void (*MOTORSTOP)(void);
typedef void (*MOTORRUN)(GPIO_PinState A, GPIO_PinState B, GPIO_PinState C, GPIO_PinState D, uint16_t delay);

typedef struct motor{
	
	
	char * name;
	uint16_t angle_n;
	uint16_t angle_pre;
	uint16_t speed;
	uint16_t *buff_pre;
	
	MOTORINIT Motor_Init;
	MOTORRUN Motor_Run;
	MOTORSTOP Motor_Stop;
	
	struct motor * ptNEXT;

	
}motor_t,* motor_p;



void Motor_Register(motor_p motorp);

void ALL_Motor(void);
motor_p Motor_Select(char * name);
void motor_Turn(motor_p motorp, int signal_time, int* status);
void motor_Turnback(motor_p motorp, int signal_time, int* status);
void motor0_stop(void);

#endif


